﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace OAuth2.Framework
{
    [Serializable]
    public class OAuthErrorResponseException<T>:Exception where T: class
    {
        #region 属性

        public T Context { get; private set; }

        public string Error { get; private set; }

        public Uri ErrorUri { get; private set; }

        public int HttpStatusCode { get; private set; }

        #endregion 

        public OAuthErrorResponseException(T context, string error) :this(){
            Context = context;
            Error = error;
            HttpStatusCode = 400;
        }

        public OAuthErrorResponseException(T context, string error, string description = "", int httpStatusCode = 400, Uri errorUri = null)
            :this(description)
        {
            ErrorUri = errorUri;
            Error = error;
            Context = context;
            HttpStatusCode = httpStatusCode;
        }

        public OAuthErrorResponseException(T context,string error,string description,Exception inner,Uri errorUri=null)
            :this(description,inner)
        {
            ErrorUri = errorUri;
            Error = error;
            Context = context;
            HttpStatusCode = 400;
        }

        private OAuthErrorResponseException() { HttpStatusCode = 400; }
        private OAuthErrorResponseException(string message) : base(message) { HttpStatusCode = 400; }
        private OAuthErrorResponseException(string message, Exception inner) : base(message, inner) { HttpStatusCode = 400; }
        protected OAuthErrorResponseException(SerializationInfo info, StreamingContext context) : base(info, context) { HttpStatusCode = 400; }
    }
}
